package com.jp.knowledge.my.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.TextView;

import com.google.zxing.client.android.ViewfinderView;
import com.jp.knowledge.R;
import com.jp.knowledge.adapter.SearchTeamCircleAdapter;
import com.jp.knowledge.adapter.team_circle.TeamCircleAdapter;
import com.jp.knowledge.comm.JpApplication;
import com.jp.knowledge.model.TeamCircleModel;
import com.jp.knowledge.my.base.RecycleVHolder;
import com.jp.knowledge.util.TimeUtil;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.List;

/**
 * Created by 528787067@qq.com on 2017/5/8.
 */

public class MyCommetsAdapter extends TeamCircleAdapter {

    private DateFormat dateFormat;

    public MyCommetsAdapter(Context context, @NonNull List<TeamCircleModel> list) {
        super(context, list);
        dateFormat = new SimpleDateFormat("MM月dd日 hh:mm");
    }

    @Override
    public void onBind(RecycleVHolder holder, int position) {
        TeamCircleModel data = mList.get(position);
        data.setTime(data.getCreateTime());
        super.onBind(holder, position);
        TextView praiseView = holder.getTextView(R.id.team_circle_chat);
        TextView chatView = holder.getTextView(R.id.team_circle_pay_reward);
        praiseView.setVisibility(View.VISIBLE);
        chatView.setVisibility(View.VISIBLE);
        praiseView.setText(data.getReplyNum()+"");
        chatView.setText(data.getPraiseNum()+"");
        praiseView.setTextColor(mContext.getResources().getColor(R.color.font_gray_think));
        chatView.setTextColor(mContext.getResources().getColor(R.color.font_gray_think));
        praiseView.setCompoundDrawablesWithIntrinsicBounds(
                mContext.getResources().getDrawable(R.mipmap.give_the_thumbs_up), null, null, null);
        chatView.setCompoundDrawablesWithIntrinsicBounds(
                mContext.getResources().getDrawable(R.mipmap.discuss), null, null, null);

        holder.get(R.id.team_circle_private).setVisibility(View.GONE);
        holder.get(R.id.team_circle_more).setVisibility(View.GONE);
        holder.get(R.id.team_circle_delete).setVisibility(View.GONE);
        holder.get(R.id.team_circle_interactive).setVisibility(View.GONE);

        TextView sendTimeTv = holder.getTextView(R.id.team_circle_time);
        try {
            sendTimeTv.setText(dateFormat.format(mList.get(position).getTime()));
            sendTimeTv.setVisibility(View.VISIBLE);
        } catch (Exception e){
            sendTimeTv.setVisibility(View.GONE);
        }
    }
}
